package com.itheima.mall.dubbo.mapper.ums;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.mall.entity.domain.ums.Menu;
import com.itheima.mall.entity.domain.ums.Resource;
import com.itheima.mall.entity.domain.ums.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 后台用户角色表 Mapper 接口
 * </p>
 *
 * @author qinglang
 * @since 2022-07-05
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    @Select("SELECT ums_menu.* FROM ums_menu,ums_role_menu_relation WHERE ums_menu.id = ums_role_menu_relation.menu_id and ums_role_menu_relation.role_id = #{id}")
    List<Menu> getMenu(Integer id);

    @Select("SELECT ums_resource.* FROM ums_resource,ums_role_resource_relation WHERE ums_resource.id = ums_role_resource_relation.resource_id and ums_role_resource_relation.role_id = #{id}")
    List<Resource> getResource(Integer id);
}
